package greedy.总结.基础;

public class leetcode1247交换字符使得字符串相同 {
    public int minimumSwap(String s1, String s2) {
        int x = 0;
        int group = 0;
        int length = s1.length();
        for (int i = 0; i < length; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                if (s1.charAt(i) == 'x') {
                    x++;
                }
                group++;
            }
        }
        return (group) % 2 == 0 ? (x % 2 == 0 ? group / 2 : group / 2 + 1) : -1;
    }
}
